package com.fr.report.web.ui;

import com.fr.base.ArrayUtils;
import com.fr.base.core.json.JSONException;
import com.fr.base.core.json.JSONObject;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.web.Repository;

public abstract class DirectWriteEditor extends FieldEditor
{
  public static final String CLICK = "click";
  public static final String AFTERINIT = "afterinit";
  protected boolean editable = true;

  public boolean isEditable()
  {
    return this.editable;
  }

  public void setEditable(boolean paramBoolean)
  {
    this.editable = paramBoolean;
  }

  public String[] supportedEvents()
  {
    return ((String[])ArrayUtils.addAll(super.supportedEvents(), new String[] { "click", "afterinit" }));
  }

  public JSONObject createJSONConfig(Object paramObject, Repository paramRepository)
    throws JSONException
  {
    JSONObject localJSONObject = super.createJSONConfig(paramObject, paramRepository);
    localJSONObject.put("editable", Boolean.valueOf(this.editable));
    return localJSONObject;
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    super.readXML(paramXMLableReader);
    if ((paramXMLableReader.isChildNode()) && (paramXMLableReader.getTagName().equals("Editable")))
      this.editable = Boolean.valueOf(paramXMLableReader.getElementValue()).booleanValue();
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    super.writeXML(paramXMLPrintWriter);
    if (!(this.editable))
      paramXMLPrintWriter.startTAG("Editable").textNode(String.valueOf(this.editable)).end();
  }

  public boolean equals(Object paramObject)
  {
    return ((paramObject instanceof DirectWriteEditor) && (super.equals(paramObject)) && (this.editable == ((DirectWriteEditor)paramObject).editable));
  }
}